Repository navigation
For you: the real plan and steps, Nudge, tests from the repo, seen-on tickets, self-hosted linking - #994
For you: the real plan and steps, Nudge, tests from the repo, seen-on tickets, self-hosted linking#994nambok wants to merge 28 commits into
Conversation
… gates and the new pull requests view A durable record per open pull request in the team's connected repositories, written from the webhooks already received for every author and kept honest by a bounded GraphQL sync under the shared GitHub budget (sweep:dashboard_prs). One function (pr_needs::decide) decides each pull request's state, its turn and what it needs next from whom; the run's watch stores its standing and the reviewer's auto-merge gate merges only what it calls ready. GET /api/prs and GET /api/prs/detail serve the dashboard's pull requests page under the "view" capability. Incident case xw holds it.
…for the org overview Every duration starts at ready for review, and human review leaves out the author and every bot. Records keep their state and turn change log, people's reviews and review requests, and check transitions. A merged or closed pull request leaves a history row kept 400 days with its run and session links and revert and follow-up links. A nightly job writes each org's and repository's snapshot and percentiles, team-scoped and bounded.
…nals A resumable 14-month backfill reads each organization's closed and merged pull requests into history under the shared budget, pausing on a held budget or rate limit and showing its progress per repository. Records keep separate author, reviewer and bot clocks, drift against the base, every check attempt (flaky reads as flaky), category and severity; history adds review coverage, bypass merges, suspect follow-ups with their reason, and CoderHelm's last run outcome and stop reason.
* The org's pull requests in one answer: GET /api/prs/overview Every pull request in the team's repositories counts, people's, CoderHelm's and other bots'; CoderHelm's are one slice. Computed facts only, with thresholds from the scope's own percentiles, no rate on fewer than 10 events, and what isn't stored yet named in `missing`. No per-person ranking, count or duration; a login appears only as one item's owner. The summary's numbers are all facts. GET /api/prs takes the overview's drill-down (stage, past p85/p95). Incident case xz pins it. * Overview: clippy's shapes, and words without hand-off phrases or loose numbers The stability line says "over the last month" so every number in the summary is a fact; the incident case reads the route's source without whitespace, so formatting can't hide a read. * A reopened change and a later alert recovery reach their waiting runs at once (#986) A run stopped because the change it built on closed now goes back to waiting as soon as GitHub reports the change reopened, not at the 15-minute sweep. The pull request handler sends the team's change check for a close or a reopen before any return a reopen reaches, naming the change, and the worker reads the runs that change's close stopped (the sweep stays the backstop for every team). A recovery posted after an alert route's quiet window now closes the run waiting on a person for that alert, through the same path a recovery posted at once uses (common::run_wake::alert_cleared, which the gateway's alert_delivery now calls too). Incident case xx_waits_never_outlive_their_event.
…re, the sync never undoes events, history is never thinned The repository's approval rule is GitHub's own review decision and the team's rule is a person's approval; a review no rule requires is named, never a hold. The sync never reopens a closed record, yields to events newer than its read, replaces the reviews and requests it lists, and marks lists cut by their page size. History rows merge by source, so the backfill never thins a row written from events. The review decision is worked out at review events and used for bypass only when fresh. Stacks join within one repository, and the detail decides with the list's own linked records.
GET /api/foryou joins the pull request records, chat_work_needs::gather and the person's open sprint from the Jira app for the session's user only: needs you now grouped by whose turn it is, the sprint with a fit band per ticket, CoderHelm's work for them, their pull requests waiting on others, Later, three private numbers and suggestions with their lifecycle. People link their Jira account from the Jira app's new "Link my CoderHelm account" action with a one-time code made on the dashboard. Give to CoderHelm adds the team's trigger label through the Jira app, so the run starts on the label path with the person as owner; "Draft a plan first" stops the run after its plan until the person approves it.
…-page # Conflicts: # services/common/src/pr_history.rs # services/gateway/src/main.rs # services/gateway/src/permissions.rs # services/worker/src/passes/incidents/bm_teams_never_cross.rs
…give The features table names the first released version with each: a site still on major 6 is told it lacks them.
…; the fit reason and version test follow 7.1.0
…fixed 1.42.3 or newer Clears the linkify-it and prosemirror-view advisories. Atlassian's editor packages pin prosemirror-view below the fix in every release, so an override lifts it.
The answer run takes up the planning run's plan (resume_from) instead of planning again with the answer in the plan's key.
# Conflicts: # docs/pull-requests.md # docs/pull-requests/api_contract.md # services/common/src/pr_history.rs # services/common/src/pr_record.rs # services/gateway/src/main.rs # services/gateway/src/permissions.rs # services/worker/src/passes/incidents/bm_teams_never_cross.rs
The link webhook reads its body into a typed struct (deny_unknown_fields, plain bounded strings, 2 KiB at most) instead of a JSON value, checks the code's signature before any read, and uses the code up only while it is unexpired, in the same conditional delete.
…en-on tickets, linking on self-hosted installs - GET /api/foryou/plan: a run's plan as written (common::plan_view), and the question to answer while it waits; the give preview shows it. - POST/DELETE /api/foryou/nudge: a GitHub comment to the one person a pull request waits on, naming who asked, once a day, with undo. - The fit's tests signal reads the repository (tree and workflows) instead of check names (foryou_tests, kept ten minutes per installation). - Is this you? carries the tickets the account was seen on. - Jira linking on self-hosted installs goes through the relay, sent once with the install's answer handed back (hybrid::relay_now). - Need rows link to /foryou/answer and /foryou/pr.
|
Auto-merge · blocked
|
| .post(format!( | ||
| "https://api.github.com/repos/{repo}/issues/{}/comments", | ||
| body.number | ||
| )) |
The link route takes Json<LinkRequest> (deny_unknown_fields, plain strings) behind a 2 KiB body limit, so no request body is deserialized by hand.
There was a problem hiding this comment.
✅ Approved with notes: nothing blocks the merge; 12 notes below are for a look.
Why approved: nothing blocks (no required rule broken, no failing check, no shown defect, no unproven critical path); 12 suggestions.
Details: PR Overview · 🎯 Risk · Also worth a look · Earlier comments
PR Overview
The PR makes For you real: the plan and step checklist a run wrote, Nudge, a tests signal read from the repository, the tickets an account was seen on, and Jira linking on self-hosted installs.
Changes
- Adds a Link my CoderHelm account issue action in the Jira app, with a UI Kit screen and a Forge resolver
- Adds sprint helpers in issues.js: JQL for the person's open sprint, story point and sprint field discovery, and a strict give request
- Adds the Forge bridge, UI Kit 12 and React 18 dependencies, and holds prosemirror-view at the fixed version or newer
- Other parts of the PR cover the gateway, common, worker and docs changes
- Jira app: new link.js sends a one-time code plus the Forge-provided account id to the gateway's /webhooks/jira-link.
- Jira app: release.js gains the sprint read (open-sprint issues with points, labels and description).
- Jira app: release.js gains the give action (assignee check, then trigger-label add or remove-then-add).
- common crate depends on subtle for constant-time comparison.
Reviewed Changes
45 changed files.
Show a summary per file
| File | Description |
|---|---|
.github/scripts/test_forge_release.py |
The behind-report test now expects the three 7.1.0 features missing on major 6, and nothing missing on 7. |
coderhelm-jira/manifest.yml |
Declares the jira:issueAction module, the linkResolver function and the link UI Kit resource. |
coderhelm-jira/package-lock.json |
The lockfile follows the dependency changes made in package.json. |
coderhelm-jira/package.json |
Adds @forge/bridge, forge/react and react, and a prosemirror-view override. |
coderhelm-jira/src/frontend/link.jsx |
UI Kit form where a person pastes the one-time code and sees the result. |
coderhelm-jira/src/issues.js |
Adds the sprint JQL, field-id discovery, sprint issue shaping, give request validation and label steps. |
coderhelm-jira/src/link-resolver.js |
Wires the linkAccount resolver to Forge, using the account id from context. |
coderhelm-jira/src/link.js |
New resolver logic: validates the account id and code, then posts them with the site's Forge secret to /webhooks/jira-link and maps the… |
coderhelm-jira/src/release.js |
Adds sprint and give branches to the get-issues handler, with a daily-cached lookup of the story point and sprint field ids. |
coderhelm-jira/test/issues.test.js |
Tests for the sprint search, field ids, sprint issue shape and the give request. |
coderhelm-jira/test/link.test.js |
Tests that link.js sends only the code, the account Forge gives and the site's proof, and that each status answer reads correctly. |
coderhelm-jira/test/manifest.test.js |
Checks the link action is an issue action and that no new web trigger is added. |
docs/for-you.md |
Documents For you: linking, plan, nudge, tests signal, fit bands and the response shape. |
docs/incidents/ya_for_you_is_only_yours.md |
The incident write-up for the privacy case, with the guarantee. |
services/Cargo.lock |
Adds the subtle crate to the lockfile. |
services/common/Cargo.toml |
Adds the subtle dependency, which services/Cargo.lock already resolves for common. |
services/common/src/foryou.rs |
New module with the For you rules: identity codes, nudges, repo tests signal, fit, grouping, suggestion lifecycle, plan approval, and… |
services/common/src/handback.rs |
Maps the new PlanApproval person-only case to the Approval human-only reason. |
services/common/src/jira_app_features.json |
Adds three features that arrive in Jira app 7.1.0. |
services/common/src/jira_app_version.rs |
Updates the version tests for the 7.1.0 features. |
services/common/src/lib.rs |
Declares the foryou and plan_view modules. |
services/common/src/plan_view.rs |
New reader that turns a run's tasks.md and design.md into steps, files and test steps. |
services/common/src/pr_history.rs |
History rows now carry the files the pull request changed. |
services/common/src/stop_judge.rs |
Adds PlanApproval and plan_first_for. A rule settles the plan-first ask with no default, and a test covers it. |
services/gateway/src/main.rs |
Registers the For you routes and /jira-link, with a named body-limit constant. |
services/gateway/src/permissions.rs |
Adds the For you handlers to the read, settings, give and reviews capabilities. |
services/gateway/src/routes/api.rs |
Extracts read_run_openspec, which returns the run's files and its run row. |
services/gateway/src/routes/chat_work.rs |
Passes the user id into Me. |
services/gateway/src/routes/chat_work_needs.rs |
Reads the Jira account from the person's own link and drops the email-based lookups. Adds a test that an email match never links an account. |
services/gateway/src/routes/deliveries.rs |
Raises the expected Delivery::new( count for hybrid.rs from 4 to 5 and updates its note, so the timing guard test accepts the new… |
services/gateway/src/routes/foryou.rs |
New For you page route. It joins pull requests, runs, sprint, tests signal, nudges and suggestions into one page, with the prefs, mark… |
services/gateway/src/routes/foryou/tests.rs |
Adds the page-build tests: needs grouping, snooze and done, suggestions, review turnaround, seen-on, the waiting row's nudge state, and… |
services/gateway/src/routes/foryou_give.rs |
New route module: the give preview, the give itself, the Jira app call, owner crediting, and a test for the three Jira app answers |
services/gateway/src/routes/foryou_link.rs |
Link code issue, unlink and not-me routes. Adds the strict LinkRequest, the relay of link requests to self-hosted installs, and… |
services/gateway/src/routes/foryou_nudge.rs |
New nudge and undo handlers, plus the live-nudge reader the For you page uses. |
services/gateway/src/routes/foryou_plan.rs |
New plan endpoint: reads a team run's tasks and design files, parses them with plan_view, and shapes the answer with awaiting_ok for a… |
services/gateway/src/routes/foryou_tests.rs |
New reader of each repository's test files and CI test command through the team's GitHub app, with a ten-minute cache and a one-minute… |
services/gateway/src/routes/hybrid.rs |
Adds relay_now: one synchronous signed relay to an install, a delivery record, and the install's status and words handed back. |
services/gateway/src/routes/hybrid_install.rs |
The install's relay intake takes the Jira events link and site_link and links the account with the code. |
services/gateway/src/routes/jira_webhook.rs |
Credits a ticket given from For you to its giver, makes the user-name write an update, and keeps seen_on ticket keys under a size… |
services/gateway/src/routes/mod.rs |
Registers the new foryou* route modules. |
services/gateway/src/routes/run_answer.rs |
An approved plan answer sets resume_from so the new run codes the plan as shown. |
services/worker/src/passes/incidents/bm_teams_never_cross.rs |
Lists forge_link as an inbound route and the two new gateway caches for the team-isolation case. |
services/worker/src/passes/incidents/ya_for_you_is_only_yours.rs |
Adds the incident case for For you's privacy rules. No route takes a user, stats are computed only for the session's own login, and an… |
services/worker/src/passes/mod.rs |
Adds the plan-first stop and approval handling in run_passes, after the clarification stop and before the plan's follow-ups are filed. |
I read the manifest wiring, the link resolver and link.js, the UI Kit screen and the new issues.js helpers. The function key, the resource path and the existing external fetch permission for api.coderhelm.com all line up. The account id comes from Forge's context rather than the payload, and it is regex-checked before it is put in JQL. npm confirms forge/react 12.6.0 and forge/bridge 7.4.0 exist.
🎯 Risk: HIGH (76/100)
██████████blast radius 100 — ~262 dependent refs; hottest: manifest.yml (~25), package-lock.json (~25), package.json (~25) · cross-repo consumers: manifest.yml to 1 repo(s), package-lock.json to 1 repo(s), package.json to 1 repo(s)██████░░░░sensitive area 60 — infra/ci, sensitive-adjacent additions████░░░░░░test coverage 40 — 38 source / 6 test file(s) changed█████████░size/spread 88 — 13277 lines across 45 file(s), spread 58%
FYI: on the whole picture nothing here holds the merge. Assumed: The flagged findings (E1-E4 correctness/validation, E8-E10 duplicate helpers) are real but reversible and can ship as named open items on the PR for a person to correct, since none reaches people outside the PR or involves irreversible harm.
Also worth a look
Advice from the smallest-change checks after the first review. They are notes, not part of the verdict:
coderhelm-jira/src/issues.js:161A parallel structure next to an existing oneservices/gateway/src/routes/jira_webhook.rs:369A parallel structure next to an existing one
Earlier comments
0 settled and resolved · 11 still open
Was this review right? Rate it 👍 / 👎 so the reviewer learns · reply @coderhelm re-review or @coderhelm <question>
| let beside = tdir == dir | ||
| || tdir == format!("{dir}/__tests__").trim_start_matches('/') | ||
| || tdir == format!("{dir}/tests").trim_start_matches('/'); |
There was a problem hiding this comment.
💬 FYI: tests_near matches every root-level test when the ticket names a code symbol (correctness, not verified)
named_files also returns backticked code names such as SavedCartsList, which have no /. In tests_near, rsplit_once('/') then gives dir = "". For such a name, beside is true for any test whose tdir is empty (tdir == dir). The {dir}/tests branch trims to "tests", so it is also true for every file directly in a root tests/ folder. The 'why' line then says with X beside the files the ticket names and cites tests unrelated to the symbol. In the repo's own test, the second named file shows the intended 'same folder' behaviour only for paths that contain a /. Only the stem rule (named_after) makes sense for a bare symbol. The result is a misleading justification on a Good fit suggestion.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| out | ||
| } | ||
|
|
||
| fn looks_like_path(p: &str) -> bool { |
There was a problem hiding this comment.
💬 FYI: Backticked code identifiers are read as files (correctness, not verified)
paths_in accepts any backticked token that looks_like_path accepts. That function only needs a stem and a 1 to 5 character alphanumeric, non-numeric extension, with no / required. Plan steps routinely quote identifiers such as req.body, user.name, props.items or self.files. Each one passes (extension body, name, items, files) and lands in Step.files and PlanView.files. PlanView.files is shown on the For you page as the files the plan changes. Because is_test_step and the tests signal read the same list, a made-up name can also change which tests are shown beside the files. The bare-word branch avoids this by requiring a /. The backtick branch has no such guard, and the unit test only covers Cargo.toml.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| return true; | ||
| } | ||
| let low = text.to_ascii_lowercase(); | ||
| ["test", "spec ", "specs", "e2e", "coverage"] |
There was a problem hiding this comment.
💬 FYI: Test-step detection matches the substring "test" inside other words (correctness, not verified)
low.contains("test") is a plain substring match. A step such as "Bump to the latest SDK", "Update the contest banner" or "Attest the signature" is marked test: true and its text is listed in PlanView.tests, which feeds the plan's test steps shown to the person. The step text is free-form, so these false positives are likely. Matching whole words fixes it.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| ["test", "spec ", "specs", "e2e", "coverage"] | |
| low.split(|c: char| !c.is_ascii_alphanumeric()) | |
| .any(|w| matches!(w, "test" | "tests" | "testing" | "spec" | "specs" | "e2e" | "coverage" | "pytest" | "jest" | "vitest")) |
| .filter(|(p, r)| p.eq_ignore_ascii_case("coderhelm") && r.contains('/')) | ||
| .map(|(_, r)| r.to_string()) |
There was a problem hiding this comment.
💬 FYI: Repository from a Jira label reaches GitHub API URLs unvalidated (hardening, not verified)
repo_hints accepts any coderhelm:<x> label that contains a '/' as a repository, and does not check it against the team's repositories. get_for_you passes the single-repo hints to foryou_tests::for_repos. That function puts the string straight into https://api.github.com/repos/{repo}, .../git/trees/... and .../contents/{p} with the team's installation token (foryou_tests.rs:49,57,80). A label such as coderhelm:a/../../x, or one with ? or #, makes the request go to a path other than /repos/<owner>/<repo>, and the cache key is built from the same string. The response is only parsed for default_branch, tree paths and workflow content, so the damage is limited. Even so, a Jira label should not choose which GitHub API path the installation token is sent to. add_reviewer in this file already checks its repo with super::reviewer::validate_repo.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| StatusCode::CONFLICT, | ||
| &format!("CoderHelm is already working on {key}."), | ||
| )); | ||
| } |
There was a problem hiding this comment.
💬 Suggestion: Give row stays after a failed Jira ask and could credit a later event (hardening)
put_given runs before ask_give. On Refused (Jira unreachable or non-200) the handler returns 409 and leaves the row. owner_for_event (jira_webhook.rs:717) credits the owner on the next Jira event for that ticket within GIVE_WINDOW_SECS (15 min), and that event can be anyone's. The credit also applies when the ticket already carries the trigger label. Then the Jira app's add changes nothing and may send no event, so a later edit by someone else takes the credit. Crediting is wanted on Old, where the message tells the person to add the label by hand. On a plain refusal or an already-labelled ticket it is probably not. Consider deleting or expiring the row on Refused, or writing it only after the Jira app answers Given. Whether a second event can arrive in the window depends on Jira's behaviour, which I couldn't check.
| .await?; | ||
| let paths: Vec<String> = tree["tree"] | ||
| .as_array()? | ||
| .iter() |
There was a problem hiding this comment.
💬 Suggestion: Truncated git tree is read as a complete one (hardening, documented)
read takes tree["tree"] from the recursive listing and never looks at tree["truncated"]. For a very large repository the list is cut off. Test files or workflow files can then be missing, and the signal would report no tests, with no sign that the read was partial. Treating a truncated tree as unreadable (None, so it is retried sooner and not trusted) would avoid a wrong fit band.
This blocks: On the tests signal's main path: a truncated tree silently reports no tests, a correctness defect the PR's tests don't exercise
Source: GitHub REST API, Get a tree: the response carries a truncated flag when the recursive listing exceeds the limit (https://docs.github.com/en/rest/git/trees#get-a-tree)
| /// Forge secret itself) or `site_link` (a hosted team's site linked to the | ||
| /// install; CoderHelm checked the secret and removed it). The answer is the | ||
| /// install's status, and its words on a refusal. | ||
| pub async fn relay_now( |
There was a problem hiding this comment.
💬 Suggestion: Public link route can relay to any install id and write delivery records unthrottled (hardening, not verified)
POST /webhooks/jira-link is public. When team_id is an install id, forge_link calls relay_now before any secret is checked on the hosted side. The install checks the secret, so this is not an auth bypass. But each unauthenticated request makes a signed outbound call (up to 8 s) to that install. It also writes a Delivery record under that install's key, so repeated bad requests can fill the install's deliveries list with failed jira.link entries. I found no per-route rate limit on the /webhooks nest in main.rs and could not check for a limit elsewhere (a gateway or WAF rule). Consider a rate limit on this route, or recording a delivery only when the install answered. Both are optional.
| pub fn jira_link_sk(user: &str) -> String { | ||
| format!("{JIRA_LINK_PREFIX}{user}") | ||
| } | ||
| pub fn give_sk(ticket: &str) -> String { |
There was a problem hiding this comment.
💬 FYI: Near-identical helpers added together (scope, not verified)
services/common/src/foryou.rs adds give_sk next to user_sk, added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/common/src/foryou.rs: <why>.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| } | ||
| } | ||
|
|
||
| fn merged_by(login: &str, n: u64, files: &[&str]) -> History { |
There was a problem hiding this comment.
💬 FYI: Near-identical helpers added together (scope, not verified)
services/gateway/src/routes/foryou/tests.rs adds merged_by next to rec, added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/gateway/src/routes/foryou/tests.rs: <why>.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
| match link(state, &team, &user, &account).await { | ||
| Ok(()) => { | ||
| info!(team_id = %team, "For you: a person linked their Jira account"); | ||
| let name = user_name(state, &team, &user).await; |
There was a problem hiding this comment.
💬 FYI: Near-identical helpers added together (scope, not verified)
services/gateway/src/routes/foryou_link.rs adds user_name next to linked_jira, added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/gateway/src/routes/foryou_link.rs: <why>.
FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.
Summary
For you without stubs, on top of #990 (its commits are in this branch until it merges): the real plan a run wrote and its step checklist, Nudge that actually reminds the person, a tests signal read from the repository, "Is this you?" with the tickets it was seen on, and Jira linking on self-hosted installs.
Changes
common::plan_viewreads a run'stasks.mdanddesign.mdinto steps per repository (done or not), the files the plan names and its test steps.GET /api/foryou/plan?run=returns it, with the question to answer while a "Draft a plan first" run waits (awaiting_ok). The give preview shows the plan the ticket's newest run wrote. An approved plan is coded as shown (resume_from, from For you: one person's own page, linked by them, never by email #990).- [x]as it goes.POST /api/foryou/nudge {repo, number}comments on the pull request, mentioning the one person it waits on and naming who asked. One a day per pull request (FORYOU#NUDGE#,common::claimwith a TTL).DELETEdeletes the comment and frees the day, only for whoever sent it. The turn and the person are read again from the team's records; a team, a check or CoderHelm is never nudged. Under the "reviews" capability.foryou_testsreads the default branch's tree and workflows through the team's GitHub app (kept ten minutes per installation and repository, listed inbm_teams_never_cross).common::test_envgives the CI test step,setup::facts::is_test_paththe test files;common::foryou::tests_signalwrites why, with the tests beside the files the ticket names. Check names are no longer used.seen_on, a string set grown under a size condition); the suggestion carries them.POST /webhooks/jira-linksends a link for an install (the app set up with the install's id, or a hosted team's site linked to one) through the relay once, synchronously, and hands the install's answer back (hybrid::relay_now). The install takes it as thejirarelay eventslinkandsite_linkand links withforyou_link::link_with_code./foryou/answerand/foryou/pr(the dashboard keeps redirects from the old addresses).docs/for-you.mdcovers all of the above.Verification
cargo fmt --all --checkandrustfmt --checkon the incident cases: cleancargo clippy -p common -p worker -p gateway --all-targets -- -D warnings: cleancargo test -p common -p worker -p gateway --no-fail-fast: every suite passes; the one failure on the first run (the deliveries timing list, which counts the new relay record) is updated and its module rerunbrand_spelling.py,domain_examples.py,text_guard.py --texton this description: clean